import type { STORAGE_MODES } from '@/enum/modules/indicator'
import type { CONTAIN_SUB } from '@/enum/modules/public'

const controller = getAjaxBaseUrl('/toolsCarbonIndicator', '/energy')

/** 碳排放配置指标管理-查计量器具下已绑定的指标 */
export function loadIndicator(toolsId: number) {
  return get(`${controller}/loadIndicator`, { toolsId })
}

/** 碳排放配置指标管理-计量器具绑定指标 */
export function bindIndicator(toolsId: number, indicatorIds: number[]) {
  return post(`${controller}/bindIndicator`, { toolsId, indicatorIds })
}

/** 碳排放配置指标管理-计量器具解除绑定指标 */
export function unbindIndicator(toolsId: number, indicatorIds: number[]) {
  return post(`${controller}/unbindIndicator`, { toolsId, indicatorIds })
}

export interface Template004ParamsType {
  pointId: number
  timeType: STORAGE_MODES
  dataTime: string
  queryText: string
  isVirtually: CONTAIN_SUB
}

export interface DataTotalOrDetailsResult {
  rowData: string[]
  tagDataVoList: { name: string, nowData: Record<string, number> }[]
  unit: string
}

/** template_004 单折线 */
export function dataTotal(params: Template004ParamsType) {
  return post<DataTotalOrDetailsResult>(`${controller}/dataTotal`, params)
}

/** template_004 多折线 */
export function dataDetails(params: Template004ParamsType) {
  return post<DataTotalOrDetailsResult>(`${controller}/dataDetails`, params)
}
